package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.RepairCourse;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 补课表 Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2023-03-09
 */
public interface RepairCourseMapper extends BaseMapper<RepairCourse> {

    @Select("select name from staff where id = #{teacher_id}")
    public abstract String getTeacherName(@Param("teacher_id")String teacherId);

    @Select("select t2.teacher_id from student_grade as t1 LEFT JOIN grade as t2 on t1.grade_id = t2.id where t1.year_part = 2023 and t1.quarter_num = 2 and t1.status = 1 and t1.grade_id = #{grade_id} group by t2.teacher_id")
    public abstract String getTeacherId(@Param("grade_id") String gradeId);

    @Select("select t2.teacher_id from student_grade as t1 LEFT JOIN grade as t2 on t1.grade_id = t2.id where t1.year_part = 2023 and t1.quarter_num = 2 and t1.status = 1 and t1.student_id = #{studentId} and subjects_id = #{subjects_id} group by t2.teacher_id")
    public abstract String getTeacherIds(@Param("student_id") String studentId ,@Param("subjects_id") String subjectsId);

    @Select("select t2.teacher_id from student_grade as t1 LEFT JOIN grade as t2 on t1.grade_id = t2.id ${ew.customSqlSegment}")
    public abstract String getTeacherIdSubject(@Param(Constants.WRAPPER)Wrapper wrapper);

}
